package com.sunplus.system.registration.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.sunplus.common.core.controller.BaseController;
import com.sunplus.common.core.domain.AjaxResult;
import com.sunplus.system.registration.domain.PortalArticle;
import com.sunplus.system.registration.service.IPortalArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文章管理Controller
 *
 * @author sunplus
 * @date 2021-03-25
 */
@RestController
@RequestMapping("/app/")
public class AppPortalArticleController extends BaseController {
    @Autowired
    private IPortalArticleService portalArticleService;

    /**
     * 查询文章管理列表
     */
    @GetMapping("portalarticle/list")
    public AjaxResult list(PortalArticle portalArticle) {
        portalArticle.setIsshowSel(0L);
        startPage();
        List<PortalArticle> list = portalArticleService.selectPortalArticleList(portalArticle);
        JSONObject data = getDataTable(list);
        return AjaxResult.success(data);
    }


    /**
     * 获取文章管理详细信息
     */
    @GetMapping(value = "portalarticle/{pid}")
    public AjaxResult getInfo(@PathVariable("pid") String pid) {
        return AjaxResult.success(portalArticleService.selectPortalArticleById(pid));
    }
}
